# import requests
from lxml import etree
# url='https://maoyan.com/board/4'
# headers={
#     'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'
# }
# response=requests.get(url=url,headers=headers)
# response.encoding=response.apparent_encoding
# print(response.text)
text=''
with open('猫眼100.html', 'r', encoding='utf-8') as file:
    text=file.read()
dom=etree.HTML(text)
for i in range(1,11):
    names=dom.xpath(f'//*[@id="app"]/div/div/div[1]/dl/dd[{i}]/div/div/div[1]/p[1]/a/text()')[0]
    stars=dom.xpath(f'//*[@id="app"]/div/div/div[1]/dl/dd[{i}]/div/div/div[1]/p[2]/text()')[0]
    releasetime=dom.xpath(f'//*[@id="app"]/div/div/div[1]/dl/dd[{i}]/div/div/div[1]/p[3]/text()')[0]
    score1=dom.xpath(f'//*[@id="app"]/div/div/div[1]/dl/dd[{i}]/div/div/div[2]/p/i[1]/text()')[0]
    score2=dom.xpath(f'//*[@id="app"]/div/div/div[1]/dl/dd[{i}]/div/div/div[2]/p/i[2]/text()')[0]
    print(names,stars.strip(),releasetime,score1+score2)


